using UnityEngine;

public class PlayerWallSlideState : EntilyState
{
    public PlayerWallSlideState(StateMachine stateMachine, string animBoolName, Player player) : base(stateMachine, animBoolName, player)
    {
    }

    public override void Enter()
    {
        base.Enter();
    }

    public override void UpDate()
    {
        base.UpDate();
        HandleWallSlide();

        if (playerInputSet.Player.Jump.WasPressedThisFrame())
        {
            stateMachine.ChangeState(player.playerJumpState);
        }

        if (player.wallDetected == false)
        {
            stateMachine.ChangeState(player.playerFallState);
        }

        if (player.groundDetected)
        {
            stateMachine.ChangeState(player.playerIdleState);
            player.Flip();
        }

        


       
    }

    public override void Exit()
    {
        base.Exit();
    }

    void HandleWallSlide()
    {
        if (player.moveInput.y<0)
        {
            player.SetVelocity(player.moveInput.x, rb.linearVelocity.y);
        }
        else
        {
            player.SetVelocity(player.moveInput.x, rb.linearVelocity.y * player.wallSlideSlowMultiplier);
        }
    }
}
